<?php
/**
*	file: intake1.php
*	path: /webroot/forms/
*	notes:   
*		this form was updated with VAIL customization on 10-16-08.
*		
*/
	//FOR DEBUGGING--comment out when done!
	ini_set('display_errors', 1);
	ini_set('error_reporting', E_ALL ^ E_NOTICE);
	error_reporting(1);

	session_start();

	$employeeSignature = $_SESSION['logged_in'];
	//echo"<h1>".$employeeSignature."</h1>";

	#get consumer information
	$query2 = "SELECT * 
				FROM consumer 
				WHERE id = ".$id;
			
	#result returned in assoc array
	$row2 = mysql_fetch_array(mysql_query($query2));

	$consumerSiganture = $row2["first_name"]." ".$row2["last_name"];

#------------------------------------------------------------------------------------------------------------

	#k now lets get the consumer's intake data
	$query = "SELECT * 
				FROM intake1  
				WHERE  consumer_id = ".$id;
	#result set				 
	$result = mysql_query($query);

	if($row = mysql_fetch_array($result)) {
		$vote = $row["voting"];
		
		$date = $row["date"];
		if($date) {
			$dateMonth = substr($date, 5, 2);
			$dateDay = substr($date, 8, 2);
			$dateYear = substr($date, 0, 4);
		}
	
		$otherName = $row["other_contact"];
		$otherPhone = $row["other_contact_phone"];
		$otherLanguage = $row["other_language_needs"];
		$otherOtherLanguage = $row["other_other_language_needs"];
		$otherLiving = $row["living_arrangement_id"];
	
		$birthDate = $row["dob"];
		if($birthDate) {
			$birthDateMonth = substr($birthDate, 5, 2);
			$birthDateDay = substr($birthDate, 8, 2);
			$birthDateYear = substr($birthDate, 0, 4);
		}
	
		$age = $row["age"];
		$sex = $row["sex_id"];
		$race = $row["race_id"];
		$maritalStatus = $row["marital_status_id"];
		$dependents = $row["dependents"];
		$dependentsHowMany = $row["dependents_count"];
		$birthCity = $row["birth_city"];
		$birthState = $row["birth_state_id"];
		$citizen = $row["citizen"];
	
		$ethnicity = $row["ethnicity"];
		$primaryDisability = $row["primary_disability_id"];
		// deprecated --> $secondaryDisability = $row["secondary_disability_id"];
		$primaryDisabilityType = $row["primary_disability_type_id"];
		//deprecated --> $secondaryDisabilityType = $row["secondary_disability_type_id"];
		$congenital = $row["congenital"];
		$traumaticInjury = $row["traumatic"];
		$disease = $row["disease"];
		$employeeSignature = $row["employee_signature"];
		$eligibilitySignoff = $row["eligibility_signoff"];
	
	
		#########################################################
		//anything REPLACED needs to be renamed in the DB field and in process file
		#########################################################
		// deprecated --> $servicesDARS = $row["services_DARS"];
		// deprecated --> $servicesDBS = $row["services_DBS"];               								//replaces -> $servicesTCB = $row["services_TCB"];
		// deprecated --> $servicesDSHS = $row["services_DSHS"];        								//replaces  -> $servicesMHMR = $row["services_MHMR"];	
		// deprecated --> $servicesDADS = $row["services_DADS"];  									//replaces -> $servicesDHS = $row["services_DHS"];
		// deprecated --> $servicesSchool = $row["services_School"];
		// deprecated --> $servicesOtherStateAgency = $row["services_Other_State_Agency"];		//replaces -> $servicesSSA = $row["services_SSA"];	
		// deprecated --> $servicesHAHA = $row["services_HAHA"];
		// deprecated --> $servicesTAN = $row["services_TAN"];
		// deprecated --> $servicesOther = $row["services_Other"];
	
		$counselorName = $row["counselor_name"];
		$counselorNumber = $row["counselor_number"];
	
		#########################################################
		# NEED TO ADD THESE VAIL PROGRAM FIELDS TO DB AND PROCESS FILE
		#########################################################
		
		//$vailProgramID1 =  1;
		$vailProgramID1 = $row["program_enrolled1"]; 
		//$vailProgramID2 =  2;
		$vailProgramID2 = $row["program_enrolled2"]; 
		//$vailProgramID3 =  3;
		$vailProgramID3 =$row["program_enrolled3"]; 
		//$vailProgramReceivedID1 =  4;
		$vailProgramReceivedID1 =$row["program_previous_enrolled1"]; 
		//$vailProgramReceivedID2 =  5;
		$vailProgramReceivedID2 =$row["program_previous_enrolled2"]; 
	
	
		#########################################################
		# NEED TO ADD THESE STATE PROGRAM FIELDS TO DB AND PROCESS FILE
		#########################################################
		
		//$stateProgramID1 =  2;
		$stateProgramID1 = $row["state_program_enrolled1"]; 
		//$stateProgramID2 =  3;
		$stateProgramID2 = $row["state_program_enrolled2"]; 
		//$stateProgramID3 =  4;
		$stateProgramID3 =$row["state_program_enrolled3"]; 
		//$stateProgramReceivedID1 =  3;
		$stateProgramReceivedID1 = $row["state_program_previous_enrolled1"]; 
		//$stateProgramReceivedID2 =  2;
		$stateProgramReceivedID2 = $row["state_program_previous_enrolled2"]; 
	
		#########################################################
		# NEED TO ADD THESE INCOME FIELDS TO DB AND PROCESS FILE
		#########################################################
		
		//$incomeSourceID1 =  2;
		$incomeSourceID1 = $row["income_source1"]; 
		//$incomeSourceID2 =  4;
		$incomeSourceID2 = $row["income_source2"]; 
		//$incomeSourceID3 =  6;
		$incomeSourceID3 = $row["income_source3"]; 
		//$incomeSourceID4 =  8;
		$incomeSourceID4 = $row["income_source4"]; 
		//$incomeSourceID5 =  10;
		$incomeSourceID5 = $row["income_source5"]; 
	
		#########################################################
		# NEED TO ADD THESE ADDITIONAL ASSISTANCE FIELDS TO DB AND PROCESS FILE
		#########################################################
		
		//$additionalAssistanceID1 =  1;
		$additionalAssistanceID1 = $row["additional_assistance1"]; 
		//$additionalAssistanceID2 =  2;
		$additionalAssistanceID2 = $row["additional_assistance2"]; 
		//$additionalAssistanceID3 =  3;
		$additionalAssistanceID3 = $row["additional_assistance3"]; 
		//$additionalAssistanceID4 =  4;
		$additionalAssistanceID4 = $row["additional_assistance4"]; 
		//$additionalAssistanceID5 =  5;
		$additionalAssistanceID5 = $row["additional_assistance5"]; 
	
		#########################################################
		# NEED TO ADD THESE REFERRAL FIELDS TO DB AND PROCESS FILE
		#########################################################
		
		//$referredToID1 =  1;
		$referredToID1 = $row["referred_to1"]; 
		//$referredToID2 =  2;
		$referredToID2 = $row["referred_to2"]; 
		//$referredFromID1 =  1;
		$referredFromID1 = $row["referred_from1"]; 
		//$referredFromID2 =  2;
		$referredFromID2 = $row["referred_from2"];  	

		
		#income fields need to be removed
		// deprecated -->$incomeJobs = $row["income_Jobs"];
		// deprecated -->$incomeSS = $row["income_SS"];
		// deprecated -->$incomeSSI = $row["income_SSI"];
		// deprecated -->$incomeSSDI = $row["income_SSDI"];
		// deprecated -->$incomePublicAssistance = $row["income_public_assistance"];
		// deprecated -->$incomeClinicCard = $row["income_clinic_card"];
		// deprecated -->$incomeWorkmansCompensation = $row["income_workmans_compensation"];
		// deprecated -->$incomePension = $row["income_pension"];
		// deprecated -->$incomeMedicare = $row["income_medicare"];
		// deprecated -->$incomeMedicaid = $row["income_medicaid"];
		// deprecated -->$incomeUnemploymentBenefits = $row["income_unemployment_benefits"];
		// deprecated -->$incomePrivateHealthInsurance = $row["income_private_health_insurance"];
		#end of income fields
		
		
		$transportationOption = $row["transportation_option_id"];
		$referralName = $row["referral_name"];
		$referralOther = $row["referral_other"];
		$capSignoff = $row["cap_signoff"];
		$waiverILP = $row["waiverILP"];
	
} else {
	
		#there was not stored intake data, so just set the date fields
		$dateMonth = date("m", mktime(date("H"),date("i"),date("s"),date("m"), date("d"), date("Y")));
		$dateDay = date("d", mktime(date("H"),date("i"),date("s"),date("m"), date("d"), date("Y")));
		$dateYear = date("Y", mktime(date("H"),date("i"),date("s"),date("m"), date("d"), date("Y")));
		$citizen = 1;
		
		//set everything else to null
		$vote = null;
		$otherName = null;
		$otherPhone = null;
		$otherLanguage = null;
		$otherOtherLanguage = null;
		$otherLiving = null;
		$age = null;
		$sex = null;
		$race = null;
		$maritalStatus =null;
		$dependents = null;
		$dependentsHowMany = null;
		$birthCity = null;
		$birthState = null;
		$citizen = null;
		$ethnicity = null;
		$primaryDisability = null;
		// deprecated --> $secondaryDisability = $row["secondary_disability_id"];
		$primaryDisabilityType = null;
		//deprecated --> $secondaryDisabilityType = $row["secondary_disability_type_id"];
		$congenital =null;
		$traumaticInjury = null;
		$disease = null;
		$employeeSignature = null;
		$eligibilitySignoff =null;
		$counselorName = null;
		$counselorNumber = null;
		$transportationOption = null;
		$referralName = null;
		$referralOther = null;
		$capSignoff = null;
		$waiverILP = null;
}
#we have our intake form data, so do something with it
?>
<form action="actions/ProcessIntake1.php" method="post"/>
	<div style="border:1px #ddd solid;padding:3px;">
		<h2>Intake Page 1</h2>
		<table class="table2">
			<tr>
				<td>
					<div class="formUnitVertical">
						<label for="vote">Do you want assistance in registering to Vote?</label>
						<br/>
						<select name="vote">
							<?php #test for stored values?>
							<option <?php if($vote==1) echo "selected "?> value="1">Yes</option>
							<option <?php if($vote==0) echo "selected "?> value="0">No</option>
						</select>
					</div>
				</td>
				<td>
					<div class="formUnitVertical">
						<label for="date">Date</label>
						<br/>
						<select name="dateMonth" id="dateMonth">
					            <option value="01">January</option>
					            <option value="02">February</option>
					            <option value="03">March</option>
					            <option value="04">April</option>
					            <option value="05">May</option>
					            <option value="06">June</option>
					            <option value="07">July</option>
					            <option value="08">August</option>
					            <option value="09">September</option>
					            <option value="10">October</option>
					            <option value="11">November</option>
					            <option value="12">December</option>
						</select>
						<script>
							//handle stored entry
							for(i=0; i<$('dateMonth').options.length; i++) {
								if($('dateMonth').options[i].value=='<? echo $dateMonth ?>') {
									$('dateMonth').options[i].selected = true;
								}
							}
						</script>
						<select name="dateDay" id="dateDay">
						<?php 
							for($i=1; $i<32; $i++) {
								if($i<10)
									echo "<option value=\"0".$i."\">".$i."</option>";
								else
									echo "<option value=\"".$i."\">".$i."</option>";
							}
						?>
						</select>
						<script>					
							for(i=0; i<$('dateDay').options.length; i++) {
								if($('dateDay').options[i].value=='<? echo $dateDay ?>') {
									$('dateDay').options[i].selected = true;
								}
							}
						</script>
						<select name="dateYear" id="dateYear">
						<?php
							for($i=0; $i<10; $i++) {
								$year = date("Y", mktime(0,0,0,1,1,date("Y")-$i));
								echo "<option value=\"".$year."\">".$year."</option>";
							}
						?>
						</select>
						<script>					
							for(i=0; i<$('dateYear').options.length; i++) {
								if($('dateYear').options[i].value=='<? echo $dateYear ?>') {
									$('dateYear').options[i].selected = true;
								}
							}
						</script>
					</div>
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<h3>Other Contact Person</h3>
				</td>
			</tr>
			<tr>
				<td>
					<div class="formUnitVertical">
						<label for="otherName">Contact Name:</label>
						<br/>
						<input type="text" name="otherName" value="<?php echo $otherName; ?>" />
					</div>
				</td>
				<td>
					<div class="formUnitVertical">
						<label for="otherPhone">Other Contact Phone Number:</label>
						<br/>
						<input type="text" name="otherPhone" value="<?php echo $otherPhone; ?>"/>
					</div>
				</td>
			</tr>

<?php
### 	CONSUMER PERSONAL INFORMATION
?>

			<tr>
				<td colspan="2">
					<h3>Consumer Information</h3>
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<table class="table2">
<?php
### 	LANGUAGE NEEDS
?>
						<tr>
							<td>
								<div class="formUnitVertical">
									<label for="otherLanguage">Language Needs:</label>
									<br/>
									<?php
										//changed this control for VAIL.  language options now dropdown control
										//<input type="text" name="otherLanguage" value="<echo $otherLanguage; "/>
									?>
									<select name="otherLanguage">
										<option value=""> --- </option>
										<option <?php if($otherLanguage=="english") echo "selected "?> value="english">English</option>
										<option <?php if($otherLanguage=="spanish") echo "selected "?> value="spanish">Spanish</option>
										<option <?php if($otherLanguage=="asl") echo "selected "?> value="asl">ASL</option>
										<option <?php if($otherLanguage=="other") echo "selected "?> value="other">Other</option>
									</select>				
								</div>
							</td>
							<td>
								<div class="formUnitVertical">
									<label for="otherOtherLanguage">Other Language Needs:</label>
									<br/>
									<?php
										//changed control for VAIL preference
										//<input type="text" name="otherOtherLanguage" value="echo $otherOtherLanguage; "/>
									?>
									<select name="otherOtherLanguage">
										<option value=""> --- </option>
										<option <?php if($otherOtherLanguage=="english") echo "selected "?> value="english">English</option>
										<option <?php if($otherOtherLanguage=="spanish") echo "selected "?> value="spanish">Spanish</option>
										<option <?php if($otherOtherLanguage=="asl") echo "selected "?> value="asl">ASL</option>
										<option <?php if($otherOtherLanguage=="other") echo "selected "?> value="other">Other</option>
									</select>	
								</div>
							</td>
						</tr>
					</table>
				</td>
			</tr>
<?php
### 	LIVING ARRANGEMENTS
?>
			<tr>
				<td colspan="2">
					<table class="table2">
						<tr>
							<td>
								<div class="formUnitVertical">
									<label for="livingArrangement">Living Arrangement:</label>
									<br/>
									<select name="otherLiving">
									<?php 
										
										//VAIL NEEDS TRHEE MORE OTIONS ADDED!
										#--with spouse
										#--with roommate
										#--attendant care
										//completed in database
										
										//pull these option from the db .  create an admin tool for VAIL to change options
										$livingQuery = "SELECT * 
														  FROM lst_living_arrangement";
										//results
										$result = mysql_query($livingQuery);

										//set living query values as select option values.  make sure to
										//see if one is stored in the db and set it as the current value
										while($row=mysql_fetch_array($result)) {
											$living_id = $row["id"];
											$name = $row["name"];
											if($otherLiving==$living_id)
												//
												echo "<option value=\"".$living_id."\" selected>".$name."</option>";
											else
												echo "<option value=\"".$living_id."\">".$name."</option>";
											}
									?>
									</select>
								</div>
							</td>
<?php
###	BIRTH DATE
?>
							<td>
								<div class="formUnitVertical">
									<label for="birthDate">Birth Date</label>
									<br/>
									<select name="birthDateMonth" id="birthDateMonth" 
												onchange="updateAge($('birthDateYear'), $('birthDateMonth'), $('birthDateDay'), $('age'))">
										<option value="01">January</option>
							                  <option value="02">February</option>
							                  <option value="03">March</option>
							                  <option value="04">April</option>
							                  <option value="05">May</option>
							                  <option value="06">June</option>
							                  <option value="07">July</option>
							                  <option value="08">August</option>
							                  <option value="09">September</option>
							                  <option value="10">October</option>
							                  <option value="11">November</option>
							                  <option value="12">December</option>
									</select>
									<script>					
										for(i=0; i<$('birthDateMonth').options.length; i++) {
											if($('birthDateMonth').options[i].value=='<? echo $birthDateMonth ?>') {
													$('birthDateMonth').options[i].selected = true;
											}
										}
									</script>
									<select name="birthDateDay" id="birthDateDay" 
												onchange="updateAge($('birthDateYear'), $('birthDateMonth'), $('birthDateDay'), $('age'))">
										<?php 
											for($i=1; $i<32; $i++) {
												if($i<10)
													echo "<option value=\"0".$i."\">".$i."</option>";
												else
													echo "<option value=\"".$i."\">".$i."</option>";
											}
										?>
									</select>
									<script>					
										for(i=0; i<$('birthDateDay').options.length; i++) {
											if($('birthDateDay').options[i].value=='<? echo $birthDateDay ?>') {
													$('birthDateDay').options[i].selected = true;
											}
										}
									</script>
									<select name="birthDateYear" id="birthDateYear" 
												onchange="updateAge($('birthDateYear'), $('birthDateMonth'), $('birthDateDay'), $('age'))">
										<?php 
											for($i=0; $i<100; $i++) {
												$year = date("Y", mktime(0,0,0,1,1,date("Y")));
												$year = intval($year) - $i;
												echo "<option value=\"".$year."\">".$year."</option>";
											}
										?>
									</select>
									<script>					
										for(i=0; i<$('birthDateYear').options.length; i++) {
											if($('birthDateYear').options[i].value=='<? echo $birthDateYear ?>') {
												$('birthDateYear').options[i].selected = true;
											}
										}
									</script>
								</div>
							</td>
							<td>
								<div class="formUnitVertical" style="width:100px">
									<label for="age">Age:</label>
									<br/>
									<input type="text" name="age" id="age" value="<?php echo $age; ?>" style="width:50px"/>
								</div>
							</td>
							<td>
								<div class="formUnitVertical">
									<label for="age">Sex:</label>
									<br/>
								<select name="sex">
								<?php 
									$sexQuery = "SELECT * FROM lst_sex";
									$result = mysql_query($sexQuery);
									
									while($row=mysql_fetch_array($result)) {
										$sex_id = $row["id"];
										$name = $row["sex"];
										if($sex==$sex_id)
											echo "<option value=\"".$sex_id."\" selected>".$name."</option>";
										else
											echo "<option value=\"".$sex_id."\">".$name."</option>";
										}
								?>
							</select>
						</div>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td colspan="2">
			<table class="table2">
				<tr>
<?php
### 	ETHNICITY
?>
					<td>
						<div class="formUnitVertical">
							<label for="ethnicity">Ethnicity:</label>
							<br/>
							<select name="ethnicity">
								<option <?php if($ethnicity=="latino") echo "selected "?> value="latino">Latino</option>
								<option <?php if($ethnicity=="non-latino") echo "selected "?> value="non-latino">Non-Latino</option>
							</select>
						</div>
					</td>
					<td>
						<div class="formUnitVertical">
							<label for="race">Race:</label>
							<br/>
							<select name="race">
							<?php 
								$raceQuery = "SELECT * FROM lst_race";
								$result = mysql_query($raceQuery);
                    
								while($row=mysql_fetch_array($result)) {
									$race_id = $row["id"];
									$name = $row["race"];
									
									if($race==$race_id)
										echo "<option value=\"".$race_id."\" selected>".$name."</option>";
									else
										echo "<option value=\"".$race_id."\">".$name."</option>";
								}
							?>
							</select>
						</div>
					</td>
<?php
### 	MARITAL STATUS 
?>
					<td>
						<div class="formUnitVertical">
							<label for="maritalStatus">Marital Status</label>
							<br/>
							<select name="maritalStatus">
							<?php 
								$maritalStatusQuery = "select * from lst_marital_status";
								$result = mysql_query($maritalStatusQuery);
                    
								while($row=mysql_fetch_array($result)) {
									$maritalStatus_id = $row["id"];
									$maritalType          = $row["status"];
									
									if($maritalStatus==$maritalStatus_id)
										echo "<option value=\"".$maritalStatus_id."\" selected>".$maritalType."</option>";
									else
										echo "<option value=\"".$maritalStatus_id."\">".$maritalType."</option>";
								}
							?>
							</select>
						</div>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
	      <td colspan="2">
			<table class="table2">
<?php
### 	DEPENDENTS 
?>
				<tr>
					<td>
						<div class="formUnitVertical">
							<label for="dependents">Dependents:</label>
							<br/>
							<select name="dependents">
								<option <?php if($dependents==1) echo "selected "?> value="1">Yes</option>
								<option <?php if($dependents==0) echo "selected "?> value="0">No</option>
							</select>
						</div>
					</td>
					<td>
						<div class="formUnitVertical">
							<label for="dependentsHowMany">If Yes, How Many?</label>
							<br/>
							<input type="text" name="dependentsHowMany" value="<?php echo $dependentsHowMany; ?>" style="width:50px"/>
						</div>
					</td>
				</tr>
			</table>
		</td>
	</tr>

<?php
### 	CONSUMER ELIGBILITY
?>
	
	<tr>
		<td colspan="2">
			<h3>Consumer Eligibility</h3>
		</td>
	</tr>
	<tr>
		<td colspan="2">
			<p>
			<label for="citizen" style="margin-right:10px">
				Are you a citizen of the United States of America? 
			</label>
			<select name="citizen">
				<option <?php if($citizen==1) echo "selected "?> value="1">Yes</option>
				<option <?php if($citizen==0) echo "selected "?> value="0">No</option>
			</select>
			</p>
		</td>
	</tr>
	
	
<?php
### 	DISABILITY INFORMATION
?>

	<tr>
		<td colspan="2">
			<h3>Disability Information</h3>
		</td>
	</tr>
	<tr>
		<td colspan="2">
			<table class="table2">
				<!-- DISABILITIES -->
				<tbody>
				<tr>
					<th><label>Category</label></th>
					<th><label>Disability Type</label></th>
				</tr>
				<tr>
				<?php
					//Woodie wants to only have a single instance for disablity information.
					//that means i need to get rid of the primary and secondary on-screen 
					//declarations, and only render one set of "Category" and "Disability Type" controls
				?>
					<td>
						<select name="primaryDisability" id="primaryDisability">
							<option value="0"></option>
								<?php
									$disCatQuery = "SELECT * 
													   FROM lst_disability_category";
									$result = mysql_query($disCatQuery);
								
									while($row=mysql_fetch_array($result)) {
										$dis_id = $row["id"];
										$category = $row["category"];
														
										if($primaryDisability==$dis_id)
											echo "<option value=\"".$dis_id."\" selected>".$category."</option>";
										else
											echo "<option value=\"".$dis_id."\">".$category."</option>";
									}
								?>
						</select>
					</td>
					<td>
						<select name="primaryDisabilityType" id="primaryDisabilityType">
							<option value="0"></option>
							<?php 
								$disTypeQuery = "SELECT * FROM lst_disability_type";
								$result = mysql_query($disTypeQuery);
								
								while($row=mysql_fetch_array($result)) {
									$dis_id = $row["id"];
									$type = $row["type"];
									
									if($primaryDisabilityType==$dis_id)
										echo "<option value=\"".$dis_id."\" selected>".$type."</option>";
									else
										echo "<option value=\"".$dis_id."\">".$type."</option>";
								}
							?>
						</select>
					</td>
				</tr>
				</tbody> 
			</table>
		</td>
    </tr>
    
    <tr>
		<td colspan="2">
			<table class="table2">
				<!-- ETIOLOGY -->
				<tbody>
				<tr>
					<td>
						<div>
							<label for="etiology">Etiology of Disability:</label>
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="checkBoxUnit">
							<label for="congenital">Congenital:</label>
							<input type="checkbox" name="congenital" <?php if($congenital=="1") echo "checked";?>/>
						</div>
					</td>
					<td>
						<div class="checkBoxUnit">
							<label for="traumaticInjury">Traumatic Injury:</label>
							<input type="checkbox" name="traumaticInjury" <?php if($traumaticInjury=="1") echo "checked";?>>
						</div>
					</td>
					<td>
						<div class="checkBoxUnit">
							<label for="disease">Disease:</label>
							<input type="checkbox" name="disease" <?php if($disease=="1") echo "checked";?>>
						</div>
					</td>
				</tr>
				</tbody>
			</table>
		</td>
	</tr>
<?php
### 	COORDINATOR SIGNOFF
?>

	<tr>
		<td>
			<div class="formUnitVertical">
				<label for="employeeSignature">Employee Signature:</label>
				<br>
				<input name="employeeSignature" value="<?php echo $employeeSignature; ?>" type="text">
			</div>
		</td>
		<td>
			<table>
				<tr>
					<td>
						<input type="checkbox" name="eligibilitySignoff" <?php if($eligibilitySignoff=="1") echo "checked";?>>
					</td>
					<td>
						<label for="eligibilitySignoff"> 
						Applicant has a significant disability as indicated 
						above, and is
						eligible for VAIL Independent Living Services. 
						</label>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	
<?php
### 	OVERALL SERVICE INFORMATION
?>

	<tr>
		<td colspan="2">
			<h3>Consumer Services Information</h3>
		</td>
	</tr>
	<tr>
		<td colspan="2">
			<label for="agencyInfoRequest"> 
				Have you received, or are currently receiving, services from 
				any of the following: 
			</label>
		</td>
	</tr>

<?php
#######################
### 	VAIL PROGRAMS 
#######################
?>

	<tr>
		<td colspan="2">
			<table class="table2">
				<!-- VAIL PROGRAMS -->
				<tbody>
				<tr>
						<td colspan="2"><h3><?php echo THIS_CIL;?> Programs</h3></td>
				</tr>
<?php
### 	ENROLLED PROGRAM 1
?>
				<tr>
					<td width="33%">
						<!-- programs box 1 -->
						<label>Currently Enrolled In:</label>
						<br>
						<select name="vailProgram1">
							<option value=""> --- </option>
							<?php
							//get list of programs 
							$vailProgramQuery = "SELECT * FROM programs";
							//result
							$vailProgramResult = mysql_query($vailProgramQuery);
						
							while($row=mysql_fetch_array($vailProgramResult)) {
								$program_id1 = $row["program_id"];
								$program_name1 = $row["program_name"];
								
								//check for stored data
								if($vailProgramID1==$program_id1)
									//if objective is stored, make sure its selected
										echo "<option value=\"".$program_id1."\" selected>".$program_name1."</option>";
									else
										echo "<option value=\"".$program_id1."\">".$program_name1."</option>";	
				
							}?>
							</select>
					</td>
<?php
### 	ENROLLED PROGRAM 2
?>
					<td width="33%">
						<!-- programs box 2 -->
						<label>Currently Enrolled In:</label>
						<br>
						<select name="vailProgram2">
							<option value=""> --- </option>
							<?php
							//get list of programs 
							$vailProgramQuery = "SELECT * FROM programs";
							//result
							$vailProgramResult = mysql_query($vailProgramQuery);
						
							while($row=mysql_fetch_array($vailProgramResult)) {
								$program_id2 = $row["program_id"];
								$program_name2 = $row["program_name"];
								
								//check for stored data
								if($vailProgramID2==$program_id2)
									//if objective is stored, make sure its selected
										echo "<option value=\"".$program_id2."\" selected>".$program_name2."</option>";
									else
										echo "<option value=\"".$program_id2."\">".$program_name2."</option>";	
				
							}?>
							</select>
					</td>
<?php
### 	ENROLLED PROGRAM 3
?>
					<td width="33%">
						<!-- programs box 3 -->
						<label>Currently Enrolled In:</label>
						<br>
						<select name="vailProgram3">
							<option value=""> --- </option>
							<?php
							//get list of programs 
							$vailProgramQuery = "SELECT * FROM programs";
							//result
							$vailProgramResult = mysql_query($vailProgramQuery);
						
							while($row=mysql_fetch_array($vailProgramResult)) {
								$program_id3 = $row["program_id"];
								$program_name3 = $row["program_name"];
								
								//check for stored data
								if($vailProgramID3==$program_id3)
									//if objective is stored, make sure its selected
										echo "<option value=\"".$program_id3."\" selected>".$program_name3."</option>";
									else
										echo "<option value=\"".$program_id3."\">".$program_name3."</option>";	
				
							}?>
							</select>
					</td>
				</tr>
				<tr>
<?php
### 	PROGRAM RECEIVED 1
?>
					<td width="33%">
						<!-- pervious programs box 1 -->
						<label>Have Received:</label>
						<br>
						<select name="vailPreviousProgram1">
							<option value=""> --- </option>
							<?php
							//get list of programs 
							$vailPreviousProgramQuery = "SELECT * FROM programs";
							//result
							$vailPreviousProgramResult = mysql_query($vailPreviousProgramQuery);
						
							while($row=mysql_fetch_array($vailPreviousProgramResult)) {
								$previous_program_id1 = $row["program_id"];
								$previous_program_name1 = $row["program_name"];
								
								//check for stored data
								if($vailProgramReceivedID1==$previous_program_id1)
									//if objective is stored, make sure its selected
										echo "<option value=\"".$previous_program_id1."\" selected>".$previous_program_name1."</option>";
									else
										echo "<option value=\"".$previous_program_id1."\">".$previous_program_name1."</option>";	
				
							}?>
							</select>
					</td>
<?php
### 	PROGRAM RECEIVED 2
?>
					<td width="33%">
						<!-- pervious programs box 2 -->
						<label>Have Received:</label>
						<br>
						<select name="vailPreviousProgram2">
							<option value=""> --- </option>
							<?php					
							//get list of programs 
							$vailPreviousProgramQuery = "SELECT * FROM programs";
							//result
							$vailPreviousProgramResult = mysql_query($vailPreviousProgramQuery);
						
							while($row=mysql_fetch_array($vailPreviousProgramResult)) {
								$previous_program_id2 = $row["program_id"];
								$previous_program_name2 = $row["program_name"];
								
								//check for stored data
								if($vailProgramReceivedID2==$previous_program_id2)
									//if objective is stored, make sure its selected
										echo "<option value=\"".$previous_program_id2."\" selected>".$previous_program_name2."</option>";
									else
										echo "<option value=\"".$previous_program_id2."\">".$previous_program_name2."</option>";	
				
							}?>
							</select>
					</td>
				</tr>

<?php
##############################
### 	STATE PROGRAMS 
##############################
?>
				<tr>
						<td colspan="2"><h3>State Programs / Services</h3></td>
				</tr>
				<tr>
<?php
### 	ENROLLED STATE PROGRAM 1
?>
					<td width="33%">
						<!-- state programs box 1 -->
						<label>Currently Enrolled In:</label>
						<br>
						<select name="stateProgram1">
							<option value=""> --- </option>
							<?php
							#THIS WILL NEEDTO BE OPTIMIZED SO SERVER LOAD IS REDUCED
					
							//get list of agencies
							$stateProgramQuery1 = "SELECT * FROM lst_agencies";
							//result
							$stateProgramResult1 = mysql_query($stateProgramQuery1);
						
							while($state_row1=mysql_fetch_array($stateProgramResult1)) {
								$state_program_id1 = $state_row1["agency_id"];
								$state_program_name1 = $state_row1["agency_name"];
								
								//check for stored data
								if($stateProgramID1==$state_program_id1)
									//if objective is stored, make sure its selected
										echo "<option value=\"".$state_program_id1."\" selected>".$state_program_name1."</option>";
									else
										echo "<option value=\"".$state_program_id1."\">".$state_program_name1."</option>";	
				
							}?>
							</select>
					</td>
<?php
### 	ENROLLED STATE PROGRAM 2
?>
					<td width="33%">
						<!-- state programs box 2 -->
						<label>Currently Enrolled In:</label>
						<br>
						<select name="stateProgram2">
							<option value=""> --- </option>
							<?php
							//get list of agencies
							$stateProgramQuery2 = "SELECT * FROM lst_agencies";
							//result
							$stateProgramResult2 = mysql_query($stateProgramQuery2);
						
							while($state_row2=mysql_fetch_array($stateProgramResult2)) {
								$state_program_id2 = $state_row2["agency_id"];
								$state_program_name2 = $state_row2["agency_name"];
								
								//check for stored data
								if($stateProgramID2==$state_program_id2)
									//if objective is stored, make sure its selected
										echo "<option value=\"".$state_program_id2."\" selected>".$state_program_name2."</option>";
									else
										echo "<option value=\"".$state_program_id2."\">".$state_program_name2."</option>";	
				
							}?>
							</select>
					</td>
<?php
### 	ENROLLED STATE PROGRAM 3
?>
					<td width="33%">
						<!-- state programs box 3 -->
						<label>Currently Enrolled In:</label>
						<br>
						<select name="stateProgram3">
							<option value=""> --- </option>
							<?php
							//get list of agencies 
							$stateProgramQuery3 = "SELECT * FROM lst_agencies";
							//result
							$stateProgramResult3 = mysql_query($stateProgramQuery3);
						
							while($state_row3=mysql_fetch_array($stateProgramResult3)) {
								$state_program_id3 = $state_row3["agency_id"];
								$state_program_name3 = $state_row3["agency_name"];
								
								//check for stored data
								if($stateProgramID3==$state_program_id3)
									//if objective is stored, make sure its selected
										echo "<option value=\"".$state_program_id3."\" selected>".$state_program_name3."</option>";
									else
										echo "<option value=\"".$state_program_id3."\">".$state_program_name3."</option>";	
				
							}?>
							</select>
					</td>
				</tr>
<?php
### 	STATE PROGRAM RECEIVED 1
?>
				<tr>
					<td width="33%">
						<!-- pervious state programs box 1 -->
						<label>Have Received:</label>
						<br>
						<select name="statePreviousProgram1">
							<option value=""> --- </option>
							<?php
							//get list of agencies
							$statePreviousProgramQuery1 = "SELECT * FROM lst_agencies";
							//result
							$statePreviousProgramResult1 = mysql_query($statePreviousProgramQuery1);
						
							while($state_previous_row1=mysql_fetch_array($statePreviousProgramResult1)) {
								$state_previous_program_id1 = $state_previous_row1["agency_id"];
								$state_previous_program_name1 = $state_previous_row1["agency_name"];
								
								//check for stored data
								if($stateProgramReceivedID1==$state_previous_program_id1)
									//if objective is stored, make sure its selected
										echo "<option value=\"".$state_previous_program_id1."\" selected>".$state_previous_program_name1."</option>";
									else
										echo "<option value=\"".$state_previous_program_id1."\">".$state_previous_program_name1."</option>";	
				
							}?>
							</select>
					</td>
<?php
### 	STATE PROGRAM RECEIVED 2
?>
					<td width="33%">
						<!-- pervious state programs box 2 -->
						<label>Have Received:</label>
						<br>
						<select name="statePreviousProgram2">
							<option value=""> --- </option>
							<?php					
							//get list of agencies 
							$statePreviousProgramQuery2 = "SELECT * FROM lst_agencies";
							//result
							$statePreviousProgramResult2 = mysql_query($statePreviousProgramQuery2);
						
							while($state_previous_row2=mysql_fetch_array($statePreviousProgramResult2)) {
								$state_previous_program_id2 = $state_previous_row2["agency_id"];
								$state_previous_program_name2 = $state_previous_row2["agency_name"];
								
								//check for stored data
								if($stateProgramReceivedID2==$state_previous_program_id2)
									//if objective is stored, make sure its selected
										echo "<option value=\"".$state_previous_program_id2."\" selected>".$state_previous_program_name2."</option>";
									else
										echo "<option value=\"".$state_previous_program_id2."\">".$state_previous_program_name2."</option>";	
				
							}?>
							</select>
					</td>			
					
				</tr>
				<tr>
					<td colspan="2">
						<!-- NESTED TABLE to hold more than one data element in a cell -->
						<table class="table2">
							<!-- CASE WORKER INFO -->
							<tbody>
							<tr>
								<td></td>
								<td></td>
							</tr>
							<tr>
								<!-- Counselor Name -->
								<td>
									<div class="formUnitVertical">
											<label>Counselor / Caseworker</label>
											<input type="text" name="counselorName" value="<?php echo $counselorName;?>">
									</div>
								</td>
								<!-- Counselor Number -->
								<td>
									<div class="formUnitVertical">
										<label>Counselor / Caseworker Phone Number</label>
										<input type="text" name="counselorNumber" value="<?php echo $counselorNumber;?>">
									</div>
								</td>
							</tr>
							</tbody>
						</table>
					</td>
				</tr>
<?php
##############################
### 	CONSUMER INCOME
##############################
?>
				<tr>
					<td colspan="2"><h3>Consumer Income</h3></td>
				</tr>
				<tr>
<?php
### 	INCOME SOURCE 1
?>
					<td width="33%">
						<!-- income box 1 -->
						<label>Income Source 1:</label>
						<br>
						<select name="incomeSource1">
							<option value=""> --- </option>
							<?php
								//get list of income sources 
								$incomeSourceQuery1 = "SELECT * FROM lst_income";
								//result
								$incomeSourceResult1 = mysql_query($incomeSourceQuery1);
						
								while($income_source_row1=mysql_fetch_array($incomeSourceResult1)) {
									$income_source_id1 = $income_source_row1["income_id"];
									$income_source_name1 = $income_source_row1["income_type"];
								
									//check for stored data
									if($incomeSourceID1==$income_source_id1)
										//if objective is stored, make sure its selected
										echo "<option value=\"".$income_source_id1."\" selected>".$income_source_name1."</option>";
									else
										echo "<option value=\"".$income_source_id1."\">".$income_source_name1."</option>";	
				
								}?>
						</select>
					</td>	
<?php
### 	INCOME SOURCE 2
?>
					<td width="33%">
						<!-- income box 2 -->
						<label>Income Source 2:</label>
						<br>
						<select name="incomeSource2">
							<option value=""> --- </option>
							<?php
								//get list of income sources 
								$incomeSourceQuery2 = "SELECT * FROM lst_income";
								//result
								$incomeSourceResult2 = mysql_query($incomeSourceQuery2);
						
								while($income_source_row2=mysql_fetch_array($incomeSourceResult2)) {
									$income_source_id2 = $income_source_row2["income_id"];
									$income_source_name2 = $income_source_row2["income_type"];
								
									//check for stored data
									if($incomeSourceID2==$income_source_id2)
										//if objective is stored, make sure its selected
										echo "<option value=\"".$income_source_id2."\" selected>".$income_source_name2."</option>";
									else
										echo "<option value=\"".$income_source_id2."\">".$income_source_name2."</option>";			
								}?>
						</select>
					</td>	
<?php
### 	INCOME SOURCE 3
?>
					<td width="33%">
						<!-- income box 3 -->
						<label>Income Source 3:</label>
						<br>
						<select name="incomeSource3">
							<option value=""> --- </option>
							<?php
								//get list of income sources 
								$incomeSourceQuery3 = "SELECT * FROM lst_income";
								//result
								$incomeSourceResult3 = mysql_query($incomeSourceQuery3);
						
								while($income_source_row3=mysql_fetch_array($incomeSourceResult3)) {
									$income_source_id3 = $income_source_row3["income_id"];
									$income_source_name3 = $income_source_row3["income_type"];
								
									//check for stored data
									if($incomeSourceID3==$income_source_id3)
										//if objective is stored, make sure its selected
										echo "<option value=\"".$income_source_id3."\" selected>".$income_source_name3."</option>";
									else
										echo "<option value=\"".$income_source_id3."\">".$income_source_name3."</option>";	
								}?>
						</select>
					</td>	
				</tr>
				<tr>
<?php
### 	INCOME SOURCE 4
?>
					<td width="33%">
						<!-- income box 4 -->
						<label>Income Source 4:</label>
						<br>
						<select name="incomeSource4">
							<option value=""> --- </option>
							<?php
								//get list of income sources 
								$incomeSourceQuery4 = "SELECT * FROM lst_income";
								//result
								$incomeSourceResult4 = mysql_query($incomeSourceQuery4);
						
								while($income_source_row4=mysql_fetch_array($incomeSourceResult4)) {
									$income_source_id4 = $income_source_row4["income_id"];
									$income_source_name4 = $income_source_row4["income_type"];
								
									//check for stored data
									if($incomeSourceID4==$income_source_id4)
										//if objective is stored, make sure its selected
										echo "<option value=\"".$income_source_id4."\" selected>".$income_source_name4."</option>";
									else
										echo "<option value=\"".$income_source_id4."\">".$income_source_name4."</option>";			
							}?>
						</select>
					</td>	
<?php
### 	INCOME SOURCE 5
?>
					<td width="33%">
						<!-- income box 5 -->
						<label>Income Source 5:</label>
						<br>
						<select name="incomeSource5">
							<option value=""> --- </option>
							<?php
								//get list of income sources 
								$incomeSourceQuery5 = "SELECT * FROM lst_income";
								//result
								$incomeSourceResult5 = mysql_query($incomeSourceQuery5);
						
								while($income_source_row5=mysql_fetch_array($incomeSourceResult5)) {
									$income_source_id5 = $income_source_row5["income_id"];
									$income_source_name5 = $income_source_row5["income_type"];
								
									//check for stored data
									if($incomeSourceID5==$income_source_id5)
										//if objective is stored, make sure its selected
										echo "<option value=\"".$income_source_id5."\" selected>".$income_source_name5."</option>";
									else
										echo "<option value=\"".$income_source_id5."\">".$income_source_name5."</option>";				
							}?>
						</select>
					</td>	
				</tr>
<?php
##############################
### 	 ADDITIONAL ASSISTANCE
##############################
?>
				<tr>
					<td colspan="2"><h3>Additional Financial or Benefits Assistance</h3></td>
				</tr>
				<tr>
<?php
### 	Additional Assistance 1
?>
					<td width="33%">
						<!-- additional assistance box 1 -->
						<label>Additional Assistance 1:</label>
						<br>
						<select name="additionalAssistance1">
							<option value=""> --- </option>
							<?php
								//get list of income sources 
								$additionalAssistanceQuery1 = "SELECT * FROM lst_additional_assistance";
								//result
								$additionalAssistanceResult1 = mysql_query($additionalAssistanceQuery1);
						
								while($additional_assistance_row1=mysql_fetch_array($additionalAssistanceResult1)) {
									$additional_assistance_id1 = $additional_assistance_row1["assistance_id"];
									$additional_assistance_name1 = $additional_assistance_row1["assistance_type"];
								
									//check for stored data
									if($additionalAssistanceID1==$additional_assistance_id1)
										//if objective is stored, make sure its selected
										echo "<option value=\"".$additional_assistance_id1."\" selected>".$additional_assistance_name1."</option>";
									else
										echo "<option value=\"".$additional_assistance_id1."\">".$additional_assistance_name1."</option>";				
							}?>
						</select>
					</td>	
<?php
### 	Additional Assistance 2
?>
					<td width="33%">
						<!-- additional assistance box 2 -->
						<label>Additional Assistance 2:</label>
						<br>
						<select name="additionalAssistance2">
							<option value=""> --- </option>
							<?php
								//get list of income sources 
								$additionalAssistanceQuery2 = "SELECT * FROM lst_additional_assistance";
								//result
								$additionalAssistanceResult2 = mysql_query($additionalAssistanceQuery2);
						
								while($additional_assistance_row2=mysql_fetch_array($additionalAssistanceResult2)) {
									$additional_assistance_id2 = $additional_assistance_row2["assistance_id"];
									$additional_assistance_name2 = $additional_assistance_row2["assistance_type"];
								
									//check for stored data
									if($additionalAssistanceID2==$additional_assistance_id2)
										//if objective is stored, make sure its selected
										echo "<option value=\"".$additional_assistance_id2."\" selected>".$additional_assistance_name2."</option>";
									else
										echo "<option value=\"".$additional_assistance_id2."\">".$additional_assistance_name2."</option>";				
							}?>
						</select>
					</td>	
<?php
### 	Additional Assistance 3
?>
					<td width="33%">
						<!-- additional assistance box 3 -->
						<label>Additional Assistance 3:</label>
						<br>
						<select name="additionalAssistance3">
							<option value=""> --- </option>
							<?php
								//get list of income sources 
								$additionalAssistanceQuery3 = "SELECT * FROM lst_additional_assistance";
								//result
								$additionalAssistanceResult3 = mysql_query($additionalAssistanceQuery3);
						
								while($additional_assistance_row3=mysql_fetch_array($additionalAssistanceResult3)) {
									$additional_assistance_id3 = $additional_assistance_row3["assistance_id"];
									$additional_assistance_name3 = $additional_assistance_row3["assistance_type"];
								
									//check for stored data
									if($additionalAssistanceID3==$additional_assistance_id3)
										//if objective is stored, make sure its selected
										echo "<option value=\"".$additional_assistance_id3."\" selected>".$additional_assistance_name3."</option>";
									else
										echo "<option value=\"".$additional_assistance_id3."\">".$additional_assistance_name3."</option>";				
							}?>
						</select>
					</td>	
				</tr>
				<tr>
				
				</tr>
<?php
### 	Additional Assistance 4
?>
					<td width="33%">
						<!-- additional assistance box 4 -->
						<label>Additional Assistance 4:</label>
						<br>
						<select name="additionalAssistance4">
							<option value=""> --- </option>
							<?php
								//get list of income sources 
								$additionalAssistanceQuery4 = "SELECT * FROM lst_additional_assistance";
								//result
								$additionalAssistanceResult4 = mysql_query($additionalAssistanceQuery4);
						
								while($additional_assistance_row4=mysql_fetch_array($additionalAssistanceResult4)) {
									$additional_assistance_id4 = $additional_assistance_row4["assistance_id"];
									$additional_assistance_name4 = $additional_assistance_row4["assistance_type"];
								
									//check for stored data
									if($additionalAssistanceID4==$additional_assistance_id4)
										//if objective is stored, make sure its selected
										echo "<option value=\"".$additional_assistance_id4."\" selected>".$additional_assistance_name4."</option>";
									else
										echo "<option value=\"".$additional_assistance_id4."\">".$additional_assistance_name4."</option>";				
							}?>
						</select>
					</td>
<?php
### 	Additional Assistance 5
?>
					<td width="33%">
						<!-- additional assistance box 5 -->
						<label>Additional Assistance 5:</label>
						<br>
						<select name="additionalAssistance5">
							<option value=""> --- </option>
							<?php
								//get list of income sources 
								$additionalAssistanceQuery5 = "SELECT * FROM lst_additional_assistance";
								//result
								$additionalAssistanceResult5 = mysql_query($additionalAssistanceQuery5);
						
								while($additional_assistance_row5=mysql_fetch_array($additionalAssistanceResult5)) {
									$additional_assistance_id5 = $additional_assistance_row5["assistance_id"];
									$additional_assistance_name5 = $additional_assistance_row5["assistance_type"];
								
									//check for stored data
									if($additionalAssistanceID5==$additional_assistance_id5)
										//if objective is stored, make sure its selected
										echo "<option value=\"".$additional_assistance_id5."\" selected>".$additional_assistance_name5."</option>";
									else
										echo "<option value=\"".$additional_assistance_id5."\">".$additional_assistance_name5."</option>";				
							}?>
						</select>
					</td>
				</tr>
<?php
### 	 TRANSPORTATION
?>
				<tr>
					<td colspan="2"><h3>Transportation</h3></td>
				</tr>
				<tr>
					<!-- Transporation -->
					<td>
						<div class="formUnitVertical">
							<label for="transporationOptions">Transporation Options:</label>
						</div>
						<select name="transportationOption">
						<?php 
							$transOptionQuery = "SELECT * FROM lst_transportation_option";
							$result = mysql_query($transOptionQuery);
							while($row=mysql_fetch_array($result)) {
								$opt_id = $row["id"];
								$name = $row["name"];
								if($transportationOption==$opt_id)
									echo "<option value=\"".$opt_id."\" selected>".$name."</option>";
								else
									echo "<option value=\"".$opt_id."\">".$name."</option>";
							}
						?>
						</select>
					</td>
				</tr>
<?php
##############################
### 	 REFERRAL ACTIVITY
##############################
?>
				<tr>
					<td colspan="2"><h3>Consumer Referral Activity</h3></td>
				</tr>
				<tr>
<?php
###  	Referred To 1
?>
					<td width="20%">
						<!-- refer to box 1 -->
						<label>Referred To 1:</label>
						<br>
						<select name="referredTo1">
							<option value=""> --- </option>
							<?php
								//get list of income sources 
								$referredToQuery1 = "SELECT * FROM lst_referred_to";
								//result
								$referredToResult1 = mysql_query($referredToQuery1);
						
								while($referred_to_row1=mysql_fetch_array($referredToResult1)) {
									$referred_to_id1 = $referred_to_row1["referred_to_id"];
									$referred_to_name1 = $referred_to_row1["referred_to_type"];
								
									//check for stored data
									if($referredToID1==$referred_to_id1)
										//if objective is stored, make sure its selected
										echo "<option value=\"".$referred_to_id1."\" selected>".$referred_to_name1."</option>";
									else
										echo "<option value=\"".$referred_to_id1."\">".$referred_to_name1."</option>";				
							}?>
						</select>
					</td>	
<?php
###  	Referred To 2
?>
					<td width="20%">
						<!-- refer to box 2 -->
						<label>Referred To 2:</label>
						<br>
						<select name="referredTo2">
							<option value=""> --- </option>
							<?php
								//get list of income sources 
								$referredToQuery2 = "SELECT * FROM lst_referred_to";
								//result
								$referredToResult2 = mysql_query($referredToQuery2);
						
								while($referred_to_row2=mysql_fetch_array($referredToResult2)) {
									$referred_to_id2 = $referred_to_row2["referred_to_id"];
									$referred_to_name2 = $referred_to_row2["referred_to_type"];
								
									//check for stored data
									if($referredToID2==$referred_to_id2)
										//if objective is stored, make sure its selected
										echo "<option value=\"".$referred_to_id2."\" selected>".$referred_to_name2."</option>";
									else
										echo "<option value=\"".$referred_to_id2."\">".$referred_to_name2."</option>";				
							}?>
						</select>
					</td>	
<?php
###  	Referred From 1
?>
					<td width="20%">
						<!-- refer from box 1 -->
						<label>Referred From 1:</label>
						<br>
						<select name="referredFrom1">
							<option value=""> --- </option>
							<?php 
								$referredFromQuery1 = "SELECT * FROM lst_referred_from";
								//result
								$referredFromResult1 = mysql_query($referredFromQuery1);
						
								while($referred_from_row1=mysql_fetch_array($referredFromResult1)) {
									$referred_from_id1 = $referred_from_row1["referred_from_id"];
									$referred_from_name1 = $referred_from_row1["referred_from_type"];
								
									//check for stored data
									if($referredFromID1==$referred_from_id1)
										//if objective is stored, make sure its selected
										echo "<option value=\"".$referred_from_id1."\" selected>".$referred_from_name1."</option>";
									else
										echo "<option value=\"".$referred_from_id1."\">".$referred_from_name1."</option>";				
							}?>
						</select>
					</td>	
<?php
###  	Referred From 2
?>
					<td width="20%">
						<!-- refer from box 2 -->
						<label>Referred From 2:</label>
						<br>
						<select name="referredFrom2">
							<option value=""> --- </option>
							<?php 
								$referredFromQuery2 = "SELECT * FROM lst_referred_from";
								//result
								$referredFromResult2 = mysql_query($referredFromQuery2);
						
								while($referred_from_row2=mysql_fetch_array($referredFromResult2)) {
									$referred_from_id2 = $referred_from_row2["referred_from_id"];
									$referred_from_name2 = $referred_from_row2["referred_from_type"];
								
									//check for stored data
									if($referredFromID2==$referred_from_id2)
										//if objective is stored, make sure its selected
										echo "<option value=\"".$referred_from_id2."\" selected>".$referred_from_name2."</option>";
									else
										echo "<option value=\"".$referred_from_id2."\">".$referred_from_name2."</option>";				
							}?>
						</select>
					</td>	
				</tr>
				
				<tr>
					<td colspan="2"><h3>CAP Information</h3></td>
				</tr>
				<tr>
						<!-- CAP Signoff -->
					<td colspan="2">
						<div class="formUnitVertical">
							<label for="capSignoff">Receipt of Information about State's Client Assistance Program?</label>
								<select name="capSignoff">
									<option value="1" <?php if($capSignoff==1) echo "selected "?>>Yes</option>
									<option <?php if($capSignoff==0) echo "selected "?> value="0">No</option>
								</select>
						</div>
					</td>
				</tr>
				<tr>
					<td style="color:#FF0000;" colspan="2">
						<label for="capScript"> 
							I, and/or my parents, family members, guardians, advocates 
							or authorized representatives have been informed and received 
							information on the availability, purpose, and use of the 
							State of Texas Client Assistance Program (CAP).  I have also been 
							informed on how to contact the CAP and
							how to seek assistance under this program. 
						</label>
					</td>
				</tr>
				<tr>
					<td colspan="2"><h3>Waiver Option</h3></td>
				</tr>
				<tr>
					<td colspan="2">
						<div class="formUnitVertical">
							<label for="waiverILP"> Waiver of Independent Living Plan </label>
						</div>
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<div class="checkBoxUnit">
							<input type="radio" name="waiverILP" value="0" align="right" <?php if($waiverILP==0) echo "checked "?> >
							<label for="waiverILPNo"> 
								NO, I will be writing an Independent Living Plan now or soon. 
							</label>
						</div>
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<div class="checkBoxUnit">
							<input type="radio" name="waiverILP" value="1" align="right" <?php if($waiverILP==1) echo "checked "?>>
							<label for="waiverILPYes"> 
								YES, I will be receiving services from the Center at this time.
								<br>
								I want to sign a waiver in lieu of making the Independent Living Plan.
								<br>
								I understand that I can request a staffing and have such a plan developed
								<br>
								at any time later on if I think it is necessary. 
							</label>
						</div>
					</td>
				</tr>
				<tr>
					<td colspan="2"><h3>Consumer Direction</h3></td>
				</tr>
				<tr>
					<td>
						<div class="formUnitVertical">
							<label for="consumerSignature">Consumer Signature:</label>
							<br>
							<?php echo $consumerSiganture; ?> 
						</div>
					</td>
				</tr>
				<tr>
					<td colspan="2">&nbsp;</td>
				</tr>
				<tr>
					<td colspan="2"align="right">
						<input type="hidden" value="<?php echo $id;?>" name="id" />
						<input type="submit" class="btn" value="Submit"/>
						<input class="btn" type="button" value="Cancel" 
									onclick="window.location='admin.php?action=cieedit&id=<?php echo $id;?>';"/>
					</td>
				</tr>
			</table>
		</div>
		<br/>
		<br/>
	</form>
</em>